import {
  q as n,
  p as F,
  ap as O,
  X as z,
  f as H,
  H as j,
  av as _,
  aw as q,
  k as m,
  m as y,
  l as v,
  az as G,
  as as l,
  aG as P,
  at as b
} from "./index-b50e6ef9.js";
import { f as W } from "./finance-81050a55.js";
function $(w) {
  const d = n([]),
    s = n(!0);
  n({}), F();
  const x = n(1),
    p = n(10),
    o = n([]),
    i = n(),
    C = O("reload"),
    f = z({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    D = z({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    S = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 50 },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "用户名", prop: "user_name", minWidth: 120 },
      { label: "手机号", prop: "user_phone", minWidth: 150 },
      { label: "来源用户", prop: "source_name", minWidth: 150 },
      { label: "来源用户手机号", prop: "source_phone", minWidth: 150 },
      { label: "冻结", prop: "money", minWidth: 120 },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e }) =>
          e == 1
            ? m(
                v("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [y("已发放")] }
              )
            : e == 2
            ? m(
                v("el-tag"),
                { class: "mx-1", type: "info", effect: "light" },
                { default: () => [y("未发放")] }
              )
            : m(
                v("el-tag"),
                { class: "mx-1", type: "info", effect: "light" },
                { default: () => [y("暂无")] }
              )
      },
      { label: "类型", prop: "type_name", minWidth: 120 },
      { label: "创建时间", prop: "create_time", minWidth: 180 }
    ],
    B = H(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function I(e) {
    G(e);
  }
  async function J(e) {
    const t = { role_id: e.role_id },
      u = JSON.stringify(t),
      g = { value: l.enc.Base64.stringify(l.enc.Utf8.parse(u)) },
      r = await P(g);
    r.code == 200
      ? (b("删除成功", { type: "success" }), C())
      : b(r.msg, { type: "error" });
  }
  function k() {}
  function L(e) {
    (p.value = e), h(void 0, e);
  }
  function N(e) {
    (x.value = e), h(e, void 0);
  }
  function U(e) {}
  function R(e) {
    (D.text = `正在加载第${e}页...`),
      (s.value = !0),
      _(600).then(() => {
        s.value = !1;
      });
  }
  async function V(e, t = []) {
    (o.value = []),
      t == null ||
        t.map(M => {
          const T = M,
            E = new Date(T);
          o.value.push(
            E.toLocaleDateString("zh-CN", {
              year: "numeric",
              month: "2-digit",
              day: "2-digit"
            })
          );
        }),
      (i.value = e),
      (s.value = !0);
    const u = {
        page: 1,
        pagesize: p.value,
        content: "freeze",
        user_phone: e.user_phone,
        type: e.type,
        start: o.value[0],
        end: o.value[1]
      },
      c = JSON.stringify(u),
      r = { value: l.enc.Base64.stringify(l.enc.Utf8.parse(c)) },
      { data: a } = await W(r);
    (d.value = a.freeze.data),
      (f.total = a.freeze.total),
      setTimeout(() => {
        s.value = !1;
      }, 500);
  }
  async function h(e = x.value, t = p.value) {
    const u = {
        page: e,
        pagesize: t,
        content: "freeze",
        user_phone: i.value ? i.value.user_phone : void 0,
        type: i.value ? i.value.type : void 0,
        start: o.value[0],
        end: o.value[1]
      },
      c = JSON.stringify(u),
      r = { value: l.enc.Base64.stringify(l.enc.Utf8.parse(c)) },
      a = await W(r);
    a.code === 200
      ? ((d.value = a.data.freeze.data),
        (f.total = a.data.freeze.total),
        setTimeout(() => {
          s.value = !1;
        }, 500))
      : b(a.msg, { type: "error" });
  }
  const A = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    j(() => {
      _().then(() => {
        const { setWatermark: e } = q(w.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        h();
    }),
    {
      loading: s,
      columns: S,
      dataList: d,
      pagination: f,
      buttonClass: B,
      onSearch: V,
      resetForm: A,
      handleaddUser: k,
      handleUpdate: I,
      handleDelete: J,
      handleSizeChange: L,
      handleCurrentChange: N,
      handleSelectionChange: U,
      onCurrentChange: R
    }
  );
}
export { $ as useRole };
